package com.xian.minespring.aop;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author zhan
 * @version 2024/1/4
 */
public class XianHandler implements InvocationHandler {
    @Override
    public Object invoke(Object bean, Method method, Object[] args) throws Throwable {
        if (method.getAnnotation(Xian.class) != null) {
            String res = (String) method.invoke(bean, args);
            if (res.contains("fuck")) {
                res = res.replace("fuck", "love");
            }
            return res;
        }
        return method.invoke(bean, args);
    }
}
